<?php

include_once 'actions.class.php';

class Oci_conn implements Actions {

    public $dbconn = null;
    public $error = false;

    function Oci_conn($dbconn) {
        $this->setDbconn($dbconn);
    }

    public function close($dbconn) {
        @oci_close($dbconn);
    }

    public function connect($stringConn) {
        $conn = @oci_connect('', '', 'localhost/XE');
        if (!$conn) {
            $e = oci_error();
            trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR);
        }
        return $conn;
    }

    public function execute($sql) {
        $res = @oci_parse($this->dbconn, $sql);
        if (!$res) {
            $e = oci_error($this->dbconn);
            trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR);
        }
        oci_execute($res);
        return $res;
    }

    public function fetchArrayAssoc($arr) {
        $rsp = array();
        $nrows = oci_fetch_all($arr, $rsp, null, null, OCI_FETCHSTATEMENT_BY_ROW + OCI_ASSOC);
        @oci_free_statement($arr);
        return ($rsp);
    }

    public function fetchArrayBoth($arr) {
        $rsp = array();
        while ($line = oci_fetch_array($arr, OCI_BOTH)) {
            array_push($rsp, $line);
        }
        @oci_free_statement($arr);
        return ($rsp);
    }

    public function fetchArrayNum($arr) {
        $rsp = array();
        $nrows = oci_fetch_all($arr, $rsp, null, null, OCI_FETCHSTATEMENT_BY_ROW + OCI_NUM);
        @oci_free_statement($arr);
        return ($rsp);
    }

    public function setDbconn($dbconn) {
        $this->dbconn = $dbconn;
    }

}

?>